<script setup>
 import { LeftOutlined, RightOutlined  } from '@ant-design/icons-vue';
import {onMounted, reactive } from 'vue';
import { bannerAPI ,hotAPI,playlistAPI} from '../../../../api'
import { useRouter } from 'vue-router'
const router = useRouter()
 let list = reactive({
   bannerDate:[],
   hotlist:[],
   playlist:[]
 })

 const getBanner = async () =>{
  const {data:res} = await bannerAPI()
  console.log(res.banners);
  list.bannerDate = res.banners
  
 }
 
const getHot = async () =>{
  const {data:res} = await hotAPI()
  list.hotlist = res.tags.slice(0,5)
 
  console.log(res.tags.slice(0,5));
}

const onChange = current => {
      console.log(current);
};
  // 获取歌单
const getplaylist = async () =>{
   const {data:res} = await playlistAPI(8)
   console.log(res.playlists);
   list.playlist = res.playlists
}
 onMounted(()=>{
  getBanner()
  getHot()
  getplaylist()
 })


</script>

<template>

  <div class="banner">
    <div class="banner-hd ws">
      <a-carousel arrows>
        <template #prevArrow>
          <div class="custom-slick-arrow" style="left: 10px; z-index: 1">
            <left-outlined />
          </div>
        </template>
        <template #nextArrow>
          <div class="custom-slick-arrow" style="right: 10px">
            <right-outlined />
          </div>
        </template>
        <div v-for="(item,index) in list.bannerDate" :key="index">
          <img :src="item.imageUrl" alt="" >
        </div>
     </a-carousel>
    </div>
  </div>
  <div class="assort">
    <div class="assorts">
      <div class="assort-left">
        <!-- 热门推荐  -->
        <div class="hot">
          <div class="hot-nav">
            <span class="title"><i class="i-pmg"></i>热门推荐</span>
            <div class="navnva">
              <template v-for="item in list.hotlist" :key="item.playlistTag.id">
              <a href="javascript:;">{{item.name}}</a>
              <span class="line" v-if="item.name !== '电子'"> | </span>
            </template>
            </div>
            <div class="more">更多</div>
          </div>
          <div class="hotlist">
            <ul>
              <li v-for="item in list.playlist " :key="item.id" @click="router.push({path:`/hpage/details/${item.id}`})">
                  <div class="hotpng">
                    <img :src="item.coverImgUrl" alt="">
                    <div class="bottom hotimg">
                      <span class="icon-headset"></span>
                      <span class="nb">{{item.playCount.toString().slice(0,3)}}万</span>
                      <span class="play"></span>
                    </div>
                    <p class="dec">
                      <a href="javascript:;" :title="item.name">{{item.name}}</a>
                    </p>
                  </div>
              </li>
              
            </ul>
          </div>
        </div>
      </div>
      <div class="assort-right">2</div>
    </div>
  </div>
</template>
<style lang="less" scoped>
* {
  margin: 0;
  padding: 0;
}
.banner {
  background: #364d79;
}
.ws {
  width: 982px;
  margin: auto;

}
li {
  list-style: none;
}
/* For demo */
.ant-carousel :deep(.slick-slide) {
  text-align: center;
  height: 285px;
  line-height: 285px;
  background: #364d79;
  overflow: hidden;
}

.ant-carousel :deep(.slick-arrow.custom-slick-arrow) {
  width: 40px;
  height: 63px;
  font-size: 25px;
  color: #fff;
  z-index: 1;
  font-size: 45px;
}

.ant-carousel :deep(.slick-prev) {
 left: -70px !important;
}
.ant-carousel :deep(.slick-next) {
  right:-70px !important;
}
.ant-carousel :deep(.custom-slick-arrow:before) {
  display: none;
}
// .ant-carousel :deep(.custom-slick-arrow:hover) {
//   opacity: 0.5;
// }

.ant-carousel :deep(.slick-slide img) {
  width: 100%;
  height: 285px;
}
.assort {
  background: #f5f5f5;
  .assorts {
    display: flex;
    width: 980px;
    margin:0 auto;
    background: #ffffff;
    border: 1px solid #d3d3d3;
    .assort-left {
      width: 730px;
      padding: 20px 20px 40px;
      .hot {
        .hot-nav {
          width: 100%;
          height: 33px;
          line-height: 23px;
          border-bottom: 2px solid #C10D0C;
          .title {
            float: left;
            font-size: 20px;
            color: #333;
            i {
              display: inline-block;
              width: 33px;
              height: 33px;
              line-height: 33px;
              background-position: -225px -156px !important;
              vertical-align: middle;
            }
            .i-pmg {
              background: url(https://s2.music.126.net/style/web2/img/index/index.png?594364704c1b21e06b59761e91e9648c) no-repeat 0 9999px;
            }
          }
          .navnva {
            float: left;
            margin: 3px 0 0 20px;
              a {
                display: inline-block;
                color: #666;
                font-size: 13px;
              }
              .line {
                margin: 0 10px;
                color: #ccc;
              }
          }
          .more {
            float: right;
            font-size: 12px;
            color: #666;
            margin-top: 3px;
            &::after {
              content: '';
              display: inline-block;
              width: 12px;
              height: 12px;
              margin-left: 4px;
              background-position: 0 -240px !important;
              vertical-align: middle;
              background: url(https://s2.music.126.net/style/web2/img/index/index.png?594364704c1b21e06b59761e91e9648c) no-repeat 0 9999px;
            }
            &:hover {
              cursor: pointer;
            }
          }
        }
        .hotlist {
          margin: 20px 0 0 0px;
          ul {
            li {
              float: left;
              width: 140px;
              height: 204px;
              margin-right: 42px;
              &:nth-child(4n) {
                margin-right: 0px;
              }
              &:hover {
                cursor: pointer;
              }
              .hotpng {
                position: relative;
                width: 140px;
                height: 140px;
                border: 1px solid #a3a3a3;
                img {
                  width: 100%;
                  height: 100%;
                }
                .bottom {
                  position: absolute;
                  left: 0;
                  bottom: 0;
                  width: 100%;
                  height: 27px;
                  line-height: 27px;
                  background-position: 0 -537px !important;
                  
                }
                .hotimg {
                  background: url(https://s2.music.126.net/style/web2/img/coverall.png?70f6e2b4fc858ee93bd00a4b6c1021d7) no-repeat;
                }
                .icon-headset {
                  display: inline-block;
                  width: 14px;
                  height: 11px;
                  background-position: 0 -24px !important;
                  margin: 9px 5px 9px 10px;
                  vertical-align: middle;
                  background: url(	https://s2.music.126.net/style/web2/img/iconall.png?777c159d3282ddb800b2aaee70cb78bb) no-repeat;
                }
                .nb {
                  color: #ccc;
                  font-size: 12px;
                }
                .play {
                  position: absolute;
                  top: 50%;
                  right: 10px;
                  transform: translateY(-50%);
                  display: inline-block;
                  width: 16px;
                  height: 17px;
                  background-position: 0 0 !important;
                  background: url(	https://s2.music.126.net/style/web2/img/iconall.png?777c159d3282ddb800b2aaee70cb78bb) no-repeat;
                }
                .dec {
                  margin: 8px 0 3px;
                  a {
                    font-size: 14px;
                    color: #000;
                  }
                }
              }
            }
          }
        }
      }
    }
  }

}
</style>